import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isCollapse: false,
    tagList: [],
    defaultActive: 'dashboard',
    defaultOrderInfo:{},
    productCheck:{},
    secondCategory:{}
  },
  mutations: {
    changeIsCollapse(state) {
      state.isCollapse = !state.isCollapse
    },
    saveTag(state, payload) {
      state.defaultActive = payload.index
      state.tagList.push(payload)
      state.tagList = [...new Set(state.tagList)]
      if (state.tagList.length > 8) {
        state.tagList.splice(0, 1)
      }
    },
    changeDefaultActive(state, payload) {
      state.defaultActive = payload.index
    },
    removeTag(state, payload) {
      state.tagList.splice(payload, 1)
    },
    closeAll(state, payload) {
      state.tagList = []
    },
    closeOther(state, payload) {
      state.tagList.filter(item => {
        if (item.index == state.defaultActive) {
          state.tagList = []
          state.tagList.push(item)
        }
      })
    },
    defaultOrder(state,payload){
      state.defaultOrderInfo = payload
    },
    saveProduct(state,info){
      state.productCheck = info
    },
    setSecondCategory(state,payload){
      state.secondCategory = payload
    }
  },
  actions: {
  },
  modules: {
  }
})
